package com.cloud.streamrabbitmqconsumer1.listener.impl;

import com.cloud.streamrabbitmqconsumer1.config.ServerConfig;
import com.cloud.streamrabbitmqconsumer1.listener.MessageListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;

import javax.annotation.Resource;

/**
 * @author kangwen
 */
@Slf4j
@EnableBinding(Sink.class)
public class StringRabbitMqMessageListener implements MessageListener<String> {

	@Resource
	private ServerConfig serverConfig;

	@StreamListener(Sink.INPUT)
	@Override
	public void listen(Message<String> message) {
		log.info("消费消息 on port{}==>{}", serverConfig.getPort(), message.getPayload());
	}
}
